home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / OLESTD.H < prev    next >
C/C++ Source or Header  |  1993-11-20  |  30KB  |  842 lines

  1. /*************************************************************************
  2. **
  3. **    OLE 2.0 Standard Utilities
  4. **
  5. **    olestd.h
  6. **
  7. **    This file contains file contains data structure defintions,
  8. **    function prototypes, constants, etc. for the common OLE 2.0
  9. **    utilities.
  10. **    These utilities include the following:
  11. **          Debuging Assert/Verify macros
  12. **          HIMETRIC conversion routines
  13. **          reference counting debug support
  14. **          OleStd API's for common compound-document app support
  15. **
  16. **    (c) Copyright Microsoft Corp. 1990 - 1992 All Rights Reserved
  17. **
  18. *************************************************************************/
  19.  
  20. #if !defined( _OLESTD_H_ )
  21. #define _OLESTD_H_
  22.  
  23. #ifndef RC_INVOKED
  24. #pragma message ("INCLUDING OLESTD.H from " __FILE__)
  25. #endif  /* RC_INVOKED */
  26.  
  27. #if defined( __TURBOC__ ) || defined( WIN32 )
  28. #define _based(a)
  29. #endif
  30.  
  31. #ifndef RC_INVOKED
  32. #include <dos.h>        // needed for filetime
  33. #endif  /* RC_INVOKED */
  34.  
  35. #include <commdlg.h>    // needed for LPPRINTDLG
  36. #include <shellapi.h>   // needed for HKEY
  37.  
  38. // String table defines...
  39. #define  IDS_OLESTDNOCREATEFILE   700
  40. #define  IDS_OLESTDNOOPENFILE     701
  41. #define  IDS_OLESTDDISKFULL       702
  42.  
  43.  
  44. /*
  45.  * Some C interface declaration stuff
  46.  */
  47.  
  48. #if ! defined(__cplusplus)
  49. typedef struct tagINTERFACEIMPL {
  50.         IUnknownVtbl FAR*       lpVtbl;
  51.         LPVOID                  lpBack;
  52.         int                     cRef;   // interface specific ref count.
  53. } INTERFACEIMPL, FAR* LPINTERFACEIMPL;
  54.  
  55. #define INIT_INTERFACEIMPL(lpIFace, pVtbl, pBack)   \
  56.         ((lpIFace)->lpVtbl = pVtbl, \
  57.             ((LPINTERFACEIMPL)(lpIFace))->lpBack = (LPVOID)pBack,   \
  58.             ((LPINTERFACEIMPL)(lpIFace))->cRef = 0  \
  59.         )
  60.  
  61. #if defined( _DEBUG )
  62. #define OleDbgQueryInterfaceMethod(lpUnk)   \
  63.         ((lpUnk) != NULL ? ((LPINTERFACEIMPL)(lpUnk))->cRef++ : 0)
  64. #define OleDbgAddRefMethod(lpThis, iface)   \
  65.         ((LPINTERFACEIMPL)(lpThis))->cRef++
  66.  
  67. #if _DEBUGLEVEL >= 2
  68. #define OleDbgReleaseMethod(lpThis, iface) \
  69.         (--((LPINTERFACEIMPL)(lpThis))->cRef == 0 ? \
  70.             OleDbgOut("\t" iface "* RELEASED (cRef == 0)\r\n"),1 : \
  71.              (((LPINTERFACEIMPL)(lpThis))->cRef < 0) ? \
  72.                 ( \
  73.                     DebugBreak(), \
  74.                     OleDbgOut(  \
  75.                         "\tERROR: " iface "* RELEASED TOO MANY TIMES\r\n") \
  76.                 ),1 : \
  77.                 1)
  78.  
  79. #else       // if _DEBUGLEVEL < 2
  80. #define OleDbgReleaseMethod(lpThis, iface) \
  81.         (--((LPINTERFACEIMPL)(lpThis))->cRef == 0 ? \
  82.             1 : \
  83.              (((LPINTERFACEIMPL)(lpThis))->cRef < 0) ? \
  84.                 ( \
  85.                     OleDbgOut(  \
  86.                         "\tERROR: " iface "* RELEASED TOO MANY TIMES\r\n") \
  87.         ),1 : \
  88.                 1)
  89.  
  90. #endif      // if _DEBUGLEVEL < 2
  91.  
  92. #else       // ! defined (_DEBUG)
  93.  
  94. #define OleDbgQueryInterfaceMethod(lpUnk)
  95. #define OleDbgAddRefMethod(lpThis, iface)
  96. #define OleDbgReleaseMethod(lpThis, iface)
  97.  
  98. #endif      // if defined( _DEBUG )
  99.  
  100. #endif      // ! defined(__cplusplus)
  101.  
  102. /*
  103.  * Some docfiles stuff
  104.  */
  105.  
  106. #define STGM_DFRALL (STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_DENY_WRITE)
  107. #define STGM_DFALL (STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_EXCLUSIVE)
  108. #define STGM_SALL (STGM_READWRITE | STGM_SHARE_EXCLUSIVE)
  109.  
  110. /*
  111.  * Some moniker stuff
  112.  */
  113.  
  114. // Delimeter used to separate ItemMoniker pieces of a composite moniker
  115. #if defined( _MAC )
  116. #define OLESTDDELIM ":"
  117. #else
  118. #define OLESTDDELIM "\\"
  119. #endif
  120.  
  121. /*
  122.  * Some Concurrency stuff
  123.  */
  124.  
  125. /* standard Delay (in msec) to wait before retrying an LRPC call.
  126. **    this value is returned from IMessageFilter::RetryRejectedCall
  127. */
  128. #define OLESTDRETRYDELAY    (DWORD)5000
  129.  
  130. /* Cancel the pending outgoing LRPC call.
  131. **    this value is returned from IMessageFilter::RetryRejectedCall
  132. */
  133. #define OLESTDCANCELRETRY   (DWORD)-1
  134.  
  135. /*
  136.  * Some Icon support stuff.
  137.  *
  138.  * The following API's are now OBSOLETE because equivalent API's have been
  139.  * added to the OLE2.DLL library
  140.  *      GetIconOfFile       superceeded by OleGetIconOfFile
  141.  *      GetIconOfClass      superceeded by OleGetIconOfClass
  142.  *      OleUIMetafilePictFromIconAndLabel
  143.  *                          superceeded by OleMetafilePictFromIconAndLabel
  144.  *
  145.  * The following macros are defined for backward compatibility with previous
  146.  * versions of the OLE2UI library. It is recommended that the new Ole* API's
  147.  * should be used instead.
  148.  */
  149. #define GetIconOfFile(hInst, lpszFileName, fUseFileAsLabel) \
  150.     OleGetIconOfFile(lpszFileName, fUseFileAsLabel)
  151.  
  152. #define GetIconOfClass(hInst, rclsid, lpszLabel, fUseTypeAsLabel) \
  153.     OleGetIconOfClass(rclsid, lpszLabel, fUseTypeAsLabel)
  154.  
  155. #define OleUIMetafilePictFromIconAndLabel(hIcon,pszLabel,pszSourceFile,iIcon)\
  156.     OleMetafilePictFromIconAndLabel(hIcon, pszLabel, pszSourceFile, iIcon)
  157.  
  158.  
  159. /*
  160.  * Some Clipboard Copy/Paste & Drag/Drop support stuff
  161.  */
  162.  
  163. //Macro to set all FormatEtc fields
  164. #define SETFORMATETC(fe, cf, asp, td, med, li)   \
  165.     ((fe).cfFormat=cf, \
  166.      (fe).dwAspect=asp, \
  167.      (fe).ptd=td, \
  168.      (fe).tymed=med, \
  169.      (fe).lindex=li)
  170.  
  171. //Macro to set interesting FormatEtc fields defaulting the others.
  172. #define SETDEFAULTFORMATETC(fe, cf, med)  \
  173.     ((fe).cfFormat=cf, \
  174.      (fe).dwAspect=DVASPECT_CONTENT, \
  175.      (fe).ptd=NULL, \
  176.      (fe).tymed=med, \
  177.      (fe).lindex=-1)
  178.  
  179. // Macro to test if two FormatEtc structures are an exact match
  180. #define IsEqualFORMATETC(fe1, fe2)  \
  181.     (OleStdCompareFormatEtc(&(fe1), &(fe2))==0)
  182.  
  183. // Clipboard format strings
  184. #define CF_EMBEDSOURCE      "Embed Source"
  185. #define CF_EMBEDDEDOBJECT   "Embedded Object"
  186. #define CF_LINKSOURCE       "Link Source"
  187. #define CF_CUSTOMLINKSOURCE "Custom Link Source"
  188. #define CF_OBJECTDESCRIPTOR "Object Descriptor"
  189. #define CF_LINKSRCDESCRIPTOR "Link Source Descriptor"
  190. #define CF_OWNERLINK        "OwnerLink"
  191. #define CF_FILENAME         "FileName"
  192.  
  193. #define OleStdQueryOleObjectData(lpformatetc)   \
  194.     (((lpformatetc)->tymed & TYMED_ISTORAGE) ?    \
  195.             NOERROR : ResultFromScode(DV_E_FORMATETC))
  196.  
  197. #define OleStdQueryLinkSourceData(lpformatetc)   \
  198.     (((lpformatetc)->tymed & TYMED_ISTREAM) ?    \
  199.             NOERROR : ResultFromScode(DV_E_FORMATETC))
  200.  
  201. #define OleStdQueryObjectDescriptorData(lpformatetc)    \
  202.     (((lpformatetc)->tymed & TYMED_HGLOBAL) ?    \
  203.             NOERROR : ResultFromScode(DV_E_FORMATETC))
  204.  
  205. #define OleStdQueryFormatMedium(lpformatetc, tymd)  \
  206.     (((lpformatetc)->tymed & tymd) ?    \
  207.             NOERROR : ResultFromScode(DV_E_FORMATETC))
  208.  
  209. // Make an independent copy of a MetafilePict
  210. #define OleStdCopyMetafilePict(hpictin, phpictout)  \
  211.     (*(phpictout) = OleDuplicateData(hpictin,CF_METAFILEPICT,GHND|GMEM_SHARE))
  212.  
  213.  
  214. // REVIEW: these need to be added to OLE2.H
  215. #if !defined( DD_DEFSCROLLINTERVAL )
  216. #define DD_DEFSCROLLINTERVAL    50
  217. #endif
  218.  
  219. #if !defined( DD_DEFDRAGDELAY )
  220. #define DD_DEFDRAGDELAY         200
  221. #endif
  222.  
  223. #if !defined( DD_DEFDRAGMINDIST )
  224. #define DD_DEFDRAGMINDIST       2
  225. #endif
  226.  
  227.  
  228. /* OleStdGetDropEffect
  229. ** -------------------
  230. **
  231. ** Convert a keyboard state into a DROPEFFECT.
  232. **
  233. ** returns the DROPEFFECT value derived from the key state.
  234. **    the following is the standard interpretation:
  235. **          no modifier -- Default Drop     (NULL is returned)
  236. **          CTRL        -- DROPEFFECT_COPY
  237. **          SHIFT       -- DROPEFFECT_MOVE
  238. **          CTRL-SHIFT  -- DROPEFFECT_LINK
  239. **
  240. **    Default Drop: this depends on the type of the target application.
  241. **    this is re-interpretable by each target application. a typical
  242. **    interpretation is if the drag is local to the same document
  243. **    (which is source of the drag) then a MOVE operation is
  244. **    performed. if the drag is not local, then a COPY operation is
  245. **    performed.
  246. */
  247. #define OleStdGetDropEffect(grfKeyState)    \
  248.     ( (grfKeyState & MK_CONTROL) ?          \
  249.         ( (grfKeyState & MK_SHIFT) ? DROPEFFECT_LINK : DROPEFFECT_COPY ) :  \
  250.         ( (grfKeyState & MK_SHIFT) ? DROPEFFECT_MOVE : 0 ) )
  251.  
  252.  
  253. /* The OLEUIPASTEFLAG enumeration is used by the OLEUIPASTEENTRY structure.
  254.  *
  255.  * OLEUIPASTE_ENABLEICON    If the container does not specify this flag for the entry in the
  256.  *   OLEUIPASTEENTRY array passed as input to OleUIPasteSpecial, the DisplayAsIcon button will be
  257.  *   unchecked and disabled when the the user selects the format that corresponds to the entry.
  258.  *
  259.  * OLEUIPASTE_PASTEONLY     Indicates that the entry in the OLEUIPASTEENTRY array is valid for pasting only.
  260.  * OLEUIPASTE_PASTE         Indicates that the entry in the OLEUIPASTEENTRY array is valid for pasting. It
  261.  *   may also be valid for linking if any of the following linking flags are specified.
  262.  *
  263.  * If the entry in the OLEUIPASTEENTRY array is valid for linking, the following flags indicate which link
  264.  * types are acceptable by OR'ing together the appropriate OLEUIPASTE_LINKTYPE<#> values.
  265.  * These values correspond as follows to the array of link types passed to OleUIPasteSpecial:
  266.  *   OLEUIPASTE_LINKTYPE1=arrLinkTypes[0]
  267.  *   OLEUIPASTE_LINKTYPE2=arrLinkTypes[1]
  268.  *   OLEUIPASTE_LINKTYPE3=arrLinkTypes[2]
  269.  *   OLEUIPASTE_LINKTYPE4=arrLinkTypes[3]
  270.  *   OLEUIPASTE_LINKTYPE5=arrLinkTypes[4]
  271.  *   OLEUIPASTE_LINKTYPE6=arrLinkTypes[5]
  272.  *   OLEUIPASTE_LINKTYPE7=arrLinkTypes[6]
  273.  *  OLEUIPASTE_LINKTYPE8=arrLinkTypes[7]
  274.  *
  275.  * where,
  276.  *   UINT arrLinkTypes[8] is an array of registered clipboard formats for linking. A maximium of 8 link
  277.  *   types are allowed.
  278.  */
  279.  
  280. typedef enum tagOLEUIPASTEFLAG
  281. {
  282.    OLEUIPASTE_ENABLEICON    = 2048,     // enable display as icon
  283.    OLEUIPASTE_PASTEONLY     = 0,
  284.    OLEUIPASTE_PASTE         = 512,
  285.    OLEUIPASTE_LINKANYTYPE   = 1024,
  286.    OLEUIPASTE_LINKTYPE1     = 1,
  287.    OLEUIPASTE_LINKTYPE2     = 2,
  288.    OLEUIPASTE_LINKTYPE3     = 4,
  289.    OLEUIPASTE_LINKTYPE4     = 8,
  290.    OLEUIPASTE_LINKTYPE5     = 16,
  291.    OLEUIPASTE_LINKTYPE6     = 32,
  292.    OLEUIPASTE_LINKTYPE7     = 64,
  293.    OLEUIPASTE_LINKTYPE8     = 128
  294. } OLEUIPASTEFLAG;
  295.  
  296. /*
  297.  * PasteEntry structure
  298.  * --------------------
  299.  * An array of OLEUIPASTEENTRY entries is specified for the PasteSpecial dialog
  300.  * box. Each entry includes a FORMATETC which specifies the formats that are
  301.  * acceptable, a string that is to represent the format in the  dialog's list
  302.  * box, a string to customize the result text of the dialog and a set of flags
  303.  * from the OLEUIPASTEFLAG enumeration.  The flags indicate if the entry is
  304.  * valid for pasting only, linking only or both pasting and linking. If the
  305.  * entry is valid for linking, the flags indicate which link types are
  306.  * acceptable by OR'ing together the appropriate OLEUIPASTE_LINKTYPE<#> values.
  307.  * These values correspond to the array of link types as follows:
  308.  *   OLEUIPASTE_LINKTYPE1=arrLinkTypes[0]
  309.  *   OLEUIPASTE_LINKTYPE2=arrLinkTypes[1]
  310.  *   OLEUIPASTE_LINKTYPE3=arrLinkTypes[2]
  311.  *   OLEUIPASTE_LINKTYPE4=arrLinkTypes[3]
  312.  *   OLEUIPASTE_LINKTYPE5=arrLinkTypes[4]
  313.  *   OLEUIPASTE_LINKTYPE6=arrLinkTypes[5]
  314.  *   OLEUIPASTE_LINKTYPE7=arrLinkTypes[6]
  315.  *   OLEUIPASTE_LINKTYPE8=arrLinkTypes[7]
  316.  *   UINT arrLinkTypes[8]; is an array of registered clipboard formats
  317.  *                        for linking. A maximium of 8 link types are allowed.
  318.  */
  319.  
  320. typedef struct tagOLEUIPASTEENTRY
  321. {
  322.    FORMATETC        fmtetc;            // Format that is acceptable. The paste
  323.                                        //   dialog checks if this format is
  324.                                        //   offered by the object on the
  325.                                        //   clipboard and if so offers it for
  326.                                        //   selection to the user.
  327.    LPCSTR           lpstrFormatName;   // String that represents the format to the user. Any %s
  328.                                        //   in this string is replaced by the FullUserTypeName
  329.                                        //   of the object on the clipboard and the resulting string
  330.                                        //   is placed in the list box of the dialog. Atmost
  331.                                        //   one %s is allowed. The presence or absence of %s indicates
  332.                                        //   if the result text is to indicate that data is
  333.                                        //   being pasted or that an object that can be activated by
  334.                                        //   an application is being pasted. If %s is
  335.                                        //   present, the result-text says that an object is being pasted.
  336.                                        //   Otherwise it says that data is being pasted.
  337.    LPCSTR           lpstrResultText;   // String to customize the result text of the dialog when
  338.                                        //  the user selects the format correspoding to this
  339.                                        //  entry. Any %s in this string is replaced by the the application
  340.                                        //  name or FullUserTypeName of the object on
  341.                                        //  the clipboard. Atmost one %s is allowed.
  342.    DWORD            dwFlags;           // Values from OLEUIPASTEFLAG enum
  343.    DWORD            dwScratchSpace;    // Scratch space available to be used
  344.                                        //   by routines which loop through an
  345.                                        //   IEnumFORMATETC* to mark if the
  346.                                        //   PasteEntry format is available.
  347.                                        //   this field CAN be left uninitialized.
  348. } OLEUIPASTEENTRY, *POLEUIPASTEENTRY, FAR *LPOLEUIPASTEENTRY;
  349.  
  350. #define OLESTDDROP_NONE         0
  351. #define OLESTDDROP_DEFAULT      1
  352. #define OLESTDDROP_NONDEFAULT   2
  353.  
  354.  
  355. /*
  356.  * Some misc stuff
  357.  */
  358.  
  359. #define EMBEDDINGFLAG "Embedding"     // Cmd line switch for launching a srvr
  360.  
  361. #define HIMETRIC_PER_INCH   2540      // number HIMETRIC units per inch
  362. #define PTS_PER_INCH        72        // number points (font size) per inch
  363.  
  364. #define MAP_PIX_TO_LOGHIM(x,ppli)   MulDiv(HIMETRIC_PER_INCH, (x), (ppli))
  365. #define MAP_LOGHIM_TO_PIX(x,ppli)   MulDiv((ppli), (x), HIMETRIC_PER_INCH)
  366.  
  367. // Returns TRUE if all fields of the two Rect's are equal, else FALSE.
  368. #define AreRectsEqual(lprc1, lprc2)     \
  369.     (((lprc1->top == lprc2->top) &&     \
  370.       (lprc1->left == lprc2->left) &&   \
  371.       (lprc1->right == lprc2->right) && \
  372.       (lprc1->bottom == lprc2->bottom)) ? TRUE : FALSE)
  373.  
  374. // The Windows "lstrcpyn" has slightly different semantics than does
  375. //  the standard-C library strncpy.  It just so happens that lstrcpyn
  376. //  has exactly the semantics we want, so we just use it.  The specific
  377. //  behavior that is needed is that the resulting string must always
  378. //  be NUL terminated, which is not the case with strncpy.  The count
  379. //  of characters (cch) is the limit on the number of characters to
  380. //  place in the resulting string including the NUL.  In other words,
  381. //  (cch) is the size of the destination buffer.
  382.  
  383. #define LSTRCPYN(lpdst, lpsrc, cch) lstrcpyn(lpdst, lpsrc, cch)
  384.  
  385. /****** DEBUG Stuff *****************************************************/
  386.  
  387. #ifdef _DEBUG
  388.  
  389. #if !defined( _DBGTRACE )
  390. #define _DEBUGLEVEL 2
  391. #else
  392. #define _DEBUGLEVEL _DBGTRACE
  393. #endif
  394.  
  395.  
  396. #if defined( NOASSERT )
  397.  
  398. #define OLEDBGASSERTDATA
  399. #define OleDbgAssert(a)
  400. #define OleDbgAssertSz(a, b)
  401. #define OleDbgVerify(a)
  402. #define OleDbgVerifySz(a, b)
  403.  
  404. #else   // ! NOASSERT
  405.  
  406. #define OLEDBGASSERTDATA    \
  407.         static char _based(_segname("_CODE")) _szAssertFile[]= __FILE__;
  408.  
  409. #define OleDbgAssert(a) \
  410.         (!(a) ? FnAssert(#a, NULL, _szAssertFile, __LINE__) : (HRESULT)1)
  411.  
  412. #define OleDbgAssertSz(a, b)    \
  413.         (!(a) ? FnAssert(#a, b, _szAssertFile, __LINE__) : (HRESULT)1)
  414.  
  415. #define OleDbgVerify(a) \
  416.         OleDbgAssert(a)
  417.  
  418. #define OleDbgVerifySz(a, b)    \
  419.         OleDbgAssertSz(a, b)
  420.  
  421. #endif  // ! NOASSERT
  422.  
  423.  
  424. #define OLEDBGDATA_MAIN(szPrefix)   \
  425.         char near g_szDbgPrefix[] = szPrefix;    \
  426.         OLEDBGASSERTDATA
  427. #define OLEDBGDATA  \
  428.         extern char near g_szDbgPrefix[];    \
  429.         OLEDBGASSERTDATA
  430.  
  431. #define OLEDBG_BEGIN(lpsz) \
  432.         OleDbgPrintAlways(g_szDbgPrefix,lpsz,1);
  433.  
  434. #define OLEDBG_END  \
  435.         OleDbgPrintAlways(g_szDbgPrefix,"End\r\n",-1);
  436.  
  437. #define OleDbgOut(lpsz) \
  438.         OleDbgPrintAlways(g_szDbgPrefix,lpsz,0)
  439.  
  440. #define OleDbgOutNoPrefix(lpsz) \
  441.         OleDbgPrintAlways("",lpsz,0)
  442.  
  443. #define OleDbgOutRefCnt(lpsz,lpObj,refcnt)      \
  444.         OleDbgPrintRefCntAlways(g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  445.  
  446. #define OleDbgOutRect(lpsz,lpRect)      \
  447.         OleDbgPrintRectAlways(g_szDbgPrefix,lpsz,lpRect)
  448.  
  449. #define OleDbgOutHResult(lpsz,hr)   \
  450.         OleDbgPrintScodeAlways(g_szDbgPrefix,lpsz,GetScode(hr))
  451.  
  452. #define OleDbgOutScode(lpsz,sc) \
  453.         OleDbgPrintScodeAlways(g_szDbgPrefix,lpsz,sc)
  454.  
  455. #define OleDbgOut1(lpsz)    \
  456.         OleDbgPrint(1,g_szDbgPrefix,lpsz,0)
  457.  
  458. #define OleDbgOutNoPrefix1(lpsz)    \
  459.         OleDbgPrint(1,"",lpsz,0)
  460.  
  461. #define OLEDBG_BEGIN1(lpsz)    \
  462.         OleDbgPrint(1,g_szDbgPrefix,lpsz,1);
  463.  
  464. #define OLEDBG_END1 \
  465.         OleDbgPrint(1,g_szDbgPrefix,"End\r\n",-1);
  466.  
  467. #define OleDbgOutRefCnt1(lpsz,lpObj,refcnt)     \
  468.         OleDbgPrintRefCnt(1,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  469.  
  470. #define OleDbgOutRect1(lpsz,lpRect)     \
  471.         OleDbgPrintRect(1,g_szDbgPrefix,lpsz,lpRect)
  472.  
  473. #define OleDbgOut2(lpsz)    \
  474.         OleDbgPrint(2,g_szDbgPrefix,lpsz,0)
  475.  
  476. #define OleDbgOutNoPrefix2(lpsz)    \
  477.         OleDbgPrint(2,"",lpsz,0)
  478.  
  479. #define OLEDBG_BEGIN2(lpsz)    \
  480.         OleDbgPrint(2,g_szDbgPrefix,lpsz,1);
  481.  
  482. #define OLEDBG_END2 \
  483.         OleDbgPrint(2,g_szDbgPrefix,"End\r\n",-1);
  484.  
  485. #define OleDbgOutRefCnt2(lpsz,lpObj,refcnt)     \
  486.         OleDbgPrintRefCnt(2,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  487.  
  488. #define OleDbgOutRect2(lpsz,lpRect)     \
  489.         OleDbgPrintRect(2,g_szDbgPrefix,lpsz,lpRect)
  490.  
  491. #define OleDbgOut3(lpsz)    \
  492.         OleDbgPrint(3,g_szDbgPrefix,lpsz,0)
  493.  
  494. #define OleDbgOutNoPrefix3(lpsz)    \
  495.         OleDbgPrint(3,"",lpsz,0)
  496.  
  497. #define OLEDBG_BEGIN3(lpsz)    \
  498.         OleDbgPrint(3,g_szDbgPrefix,lpsz,1);
  499.  
  500. #define OLEDBG_END3 \
  501.         OleDbgPrint(3,g_szDbgPrefix,"End\r\n",-1);
  502.  
  503. #define OleDbgOutRefCnt3(lpsz,lpObj,refcnt)     \
  504.         OleDbgPrintRefCnt(3,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  505.  
  506. #define OleDbgOutRect3(lpsz,lpRect)     \
  507.         OleDbgPrintRect(3,g_szDbgPrefix,lpsz,lpRect)
  508.  
  509. #define OleDbgOut4(lpsz)    \
  510.         OleDbgPrint(4,g_szDbgPrefix,lpsz,0)
  511.  
  512. #define OleDbgOutNoPrefix4(lpsz)    \
  513.         OleDbgPrint(4,"",lpsz,0)
  514.  
  515. #define OLEDBG_BEGIN4(lpsz)    \
  516.         OleDbgPrint(4,g_szDbgPrefix,lpsz,1);
  517.  
  518. #define OLEDBG_END4 \
  519.         OleDbgPrint(4,g_szDbgPrefix,"End\r\n",-1);
  520.  
  521. #define OleDbgOutRefCnt4(lpsz,lpObj,refcnt)     \
  522.         OleDbgPrintRefCnt(4,g_szDbgPrefix,lpsz,lpObj,(ULONG)refcnt)
  523.  
  524. #define OleDbgOutRect4(lpsz,lpRect)     \
  525.         OleDbgPrintRect(4,g_szDbgPrefix,lpsz,lpRect)
  526.  
  527. #else   //  !_DEBUG
  528.  
  529. #define OLEDBGDATA_MAIN(szPrefix)
  530. #define OLEDBGDATA
  531. #define OleDbgAssert(a)
  532. #define OleDbgAssertSz(a, b)
  533. #define OleDbgVerify(a)         (a)
  534. #define OleDbgVerifySz(a, b)    (a)
  535. #define OleDbgOutHResult(lpsz,hr)
  536. #define OleDbgOutScode(lpsz,sc)
  537. #define OLEDBG_BEGIN(lpsz)
  538. #define OLEDBG_END
  539. #define OleDbgOut(lpsz)
  540. #define OleDbgOut1(lpsz)
  541. #define OleDbgOut2(lpsz)
  542. #define OleDbgOut3(lpsz)
  543. #define OleDbgOut4(lpsz)
  544. #define OleDbgOutNoPrefix(lpsz)
  545. #define OleDbgOutNoPrefix1(lpsz)
  546. #define OleDbgOutNoPrefix2(lpsz)
  547. #define OleDbgOutNoPrefix3(lpsz)
  548. #define OleDbgOutNoPrefix4(lpsz)
  549. #define OLEDBG_BEGIN1(lpsz)
  550. #define OLEDBG_BEGIN2(lpsz)
  551. #define OLEDBG_BEGIN3(lpsz)
  552. #define OLEDBG_BEGIN4(lpsz)
  553. #define OLEDBG_END1
  554. #define OLEDBG_END2
  555. #define OLEDBG_END3
  556. #define OLEDBG_END4
  557. #define OleDbgOutRefCnt(lpsz,lpObj,refcnt)
  558. #define OleDbgOutRefCnt1(lpsz,lpObj,refcnt)
  559. #define OleDbgOutRefCnt2(lpsz,lpObj,refcnt)
  560. #define OleDbgOutRefCnt3(lpsz,lpObj,refcnt)
  561. #define OleDbgOutRefCnt4(lpsz,lpObj,refcnt)
  562. #define OleDbgOutRect(lpsz,lpRect)
  563. #define OleDbgOutRect1(lpsz,lpRect)
  564. #define OleDbgOutRect2(lpsz,lpRect)
  565. #define OleDbgOutRect3(lpsz,lpRect)
  566. #define OleDbgOutRect4(lpsz,lpRect)
  567.  
  568. #endif  //  _DEBUG
  569.  
  570.  
  571. /*************************************************************************
  572. ** Function prototypes
  573. *************************************************************************/
  574.  
  575.  
  576. //OLESTD.C
  577. STDAPI_(int) SetDCToAnisotropic(HDC hDC, LPRECT lprcPhysical, LPRECT lprcLogical, LPRECT lprcWindowOld, LPRECT lprcViewportOld);
  578. STDAPI_(int) SetDCToDrawInHimetricRect(HDC, LPRECT, LPRECT, LPRECT, LPRECT);
  579. STDAPI_(int) ResetOrigDC(HDC, int, LPRECT, LPRECT);
  580.  
  581. STDAPI_(int)        XformWidthInHimetricToPixels(HDC, int);
  582. STDAPI_(int)        XformWidthInPixelsToHimetric(HDC, int);
  583. STDAPI_(int)        XformHeightInHimetricToPixels(HDC, int);
  584. STDAPI_(int)        XformHeightInPixelsToHimetric(HDC, int);
  585.  
  586. STDAPI_(void) XformRectInPixelsToHimetric(HDC, LPRECT, LPRECT);
  587. STDAPI_(void) XformRectInHimetricToPixels(HDC, LPRECT, LPRECT);
  588. STDAPI_(void) XformSizeInPixelsToHimetric(HDC, LPSIZEL, LPSIZEL);
  589. STDAPI_(void) XformSizeInHimetricToPixels(HDC, LPSIZEL, LPSIZEL);
  590. STDAPI_(int) XformWidthInHimetricToPixels(HDC, int);
  591. STDAPI_(int) XformWidthInPixelsToHimetric(HDC, int);
  592. STDAPI_(int) XformHeightInHimetricToPixels(HDC, int);
  593. STDAPI_(int) XformHeightInPixelsToHimetric(HDC, int);
  594.  
  595. STDAPI_(void) ParseCmdLine(LPSTR, BOOL FAR *, LPSTR);
  596.  
  597. STDAPI_(BOOL) OleStdIsOleLink(LPUNKNOWN lpUnk);
  598. STDAPI_(LPUNKNOWN) OleStdQueryInterface(LPUNKNOWN lpUnk, REFIID riid);
  599. STDAPI_(LPSTORAGE) OleStdCreateRootStorage(LPSTR lpszStgName, DWORD grfMode);
  600. STDAPI_(LPSTORAGE) OleStdOpenRootStorage(LPSTR lpszStgName, DWORD grfMode);
  601. STDAPI_(LPSTORAGE) OleStdOpenOrCreateRootStorage(LPSTR lpszStgName, DWORD grfMode);
  602. STDAPI_(LPSTORAGE) OleStdCreateChildStorage(LPSTORAGE lpStg, LPSTR lpszStgName);
  603. STDAPI_(LPSTORAGE) OleStdOpenChildStorage(LPSTORAGE lpStg, LPSTR lpszStgName, DWORD grfMode);
  604. STDAPI_(BOOL) OleStdCommitStorage(LPSTORAGE lpStg);
  605. STDAPI OleStdDestroyAllElements(LPSTORAGE lpStg);
  606.  
  607. STDAPI_(LPSTORAGE) OleStdCreateStorageOnHGlobal(
  608.         HANDLE hGlobal,
  609.         BOOL fDeleteOnRelease,
  610.         DWORD dwgrfMode
  611. );
  612. STDAPI_(LPSTORAGE) OleStdCreateTempStorage(BOOL fUseMemory, DWORD grfMode);
  613. STDAPI OleStdDoConvert(LPSTORAGE lpStg, REFCLSID rClsidNew);
  614. STDAPI_(BOOL) OleStdGetTreatAsFmtUserType(
  615.         REFCLSID        rClsidApp,
  616.         LPSTORAGE       lpStg,
  617.         CLSID FAR*      lpclsid,
  618.         CLIPFORMAT FAR* lpcfFmt,
  619.         LPSTR FAR*      lplpszType
  620. );
  621. STDAPI OleStdDoTreatAsClass(LPSTR lpszUserType, REFCLSID rclsid, REFCLSID rclsidNew);
  622. STDAPI_(BOOL) OleStdSetupAdvises(LPOLEOBJECT lpOleObject, DWORD dwDrawAspect,
  623.                     LPSTR lpszContainerApp, LPSTR lpszContainerObj,
  624.                     LPADVISESINK lpAdviseSink, BOOL fCreate);
  625. STDAPI OleStdSwitchDisplayAspect(
  626.         LPOLEOBJECT             lpOleObj,
  627.         LPDWORD                 lpdwCurAspect,
  628.         DWORD                   dwNewAspect,
  629.         HGLOBAL                 hMetaPict,
  630.         BOOL                    fDeleteOldAspect,
  631.         BOOL                    fSetupViewAdvise,
  632.         LPADVISESINK            lpAdviseSink,
  633.         BOOL FAR*               lpfMustUpdate
  634. );
  635. STDAPI OleStdSetIconInCache(LPOLEOBJECT lpOleObj, HGLOBAL hMetaPict);
  636. STDAPI_(HGLOBAL) OleStdGetData(
  637.         LPDATAOBJECT        lpDataObj,
  638.         CLIPFORMAT          cfFormat,
  639.         DVTARGETDEVICE FAR* lpTargetDevice,
  640.         DWORD               dwAspect,
  641.         LPSTGMEDIUM         lpMedium
  642. );
  643. STDAPI_(void) OleStdMarkPasteEntryList(
  644.         LPDATAOBJECT        lpSrcDataObj,
  645.         LPOLEUIPASTEENTRY   lpPriorityList,
  646.         int                 cEntries
  647. );
  648. STDAPI_(int) OleStdGetPriorityClipboardFormat(
  649.         LPDATAOBJECT        lpSrcDataObj,
  650.         LPOLEUIPASTEENTRY   lpPriorityList,
  651.         int                 cEntries
  652. );
  653. STDAPI_(BOOL) OleStdIsDuplicateFormat(
  654.         LPFORMATETC         lpFmtEtc,
  655.         LPFORMATETC         arrFmtEtc,
  656.         int                 nFmtEtc
  657. );
  658. STDAPI_(void) OleStdRegisterAsRunning(LPUNKNOWN lpUnk, LPMONIKER lpmkFull, DWORD FAR* lpdwRegister);
  659. STDAPI_(void) OleStdRevokeAsRunning(DWORD FAR* lpdwRegister);
  660. STDAPI_(void) OleStdNoteFileChangeTime(LPSTR lpszFileName, DWORD dwRegister);
  661. STDAPI_(void) OleStdNoteObjectChangeTime(DWORD dwRegister);
  662. STDAPI OleStdGetOleObjectData(
  663.         LPPERSISTSTORAGE    lpPStg,
  664.         LPFORMATETC         lpformatetc,
  665.         LPSTGMEDIUM         lpMedium,
  666.         BOOL                fUseMemory
  667. );
  668. STDAPI OleStdGetLinkSourceData(
  669.         LPMONIKER           lpmk,
  670.         LPCLSID             lpClsID,
  671.         LPFORMATETC         lpformatetc,
  672.         LPSTGMEDIUM         lpMedium
  673. );
  674. STDAPI_(HGLOBAL) OleStdGetObjectDescriptorData(
  675.         CLSID               clsid,
  676.         DWORD               dwAspect,
  677.         SIZEL               sizel,
  678.         POINTL              pointl,
  679.         DWORD               dwStatus,
  680.         LPSTR               lpszFullUserTypeName,
  681.         LPSTR               lpszSrcOfCopy
  682. );
  683. STDAPI_(HGLOBAL) OleStdGetObjectDescriptorDataFromOleObject(
  684.         LPOLEOBJECT         lpOleObj,
  685.         LPSTR               lpszSrcOfCopy,
  686.         DWORD               dwAspect,
  687.         POINTL              pointl,
  688.         LPSIZEL             lpSizelHim
  689. );
  690. STDAPI_(HGLOBAL) OleStdFillObjectDescriptorFromData(
  691.         LPDATAOBJECT       lpDataObject,
  692.         LPSTGMEDIUM        lpmedium,
  693.         CLIPFORMAT FAR*    lpcfFmt
  694. );
  695. STDAPI_(HANDLE) OleStdGetMetafilePictFromOleObject(
  696.         LPOLEOBJECT         lpOleObj,
  697.         DWORD               dwDrawAspect,
  698.         LPSIZEL             lpSizelHim,
  699.         DVTARGETDEVICE FAR* ptd
  700. );
  701.  
  702. STDAPI_(void) OleStdCreateTempFileMoniker(LPSTR lpszPrefixString, UINT FAR* lpuUnique, LPSTR lpszName, LPMONIKER FAR* lplpmk);
  703. STDAPI_(LPMONIKER) OleStdGetFirstMoniker(LPMONIKER lpmk);
  704. STDAPI_(ULONG) OleStdGetLenFilePrefixOfMoniker(LPMONIKER lpmk);
  705. STDAPI OleStdMkParseDisplayName(
  706.         REFCLSID        rClsid,
  707.         LPBC            lpbc,
  708.         LPSTR           lpszUserName,
  709.         ULONG FAR*      lpchEaten,
  710.         LPMONIKER FAR*  lplpmk
  711. );
  712. STDAPI_(LPVOID) OleStdMalloc(ULONG ulSize);
  713. STDAPI_(LPVOID) OleStdRealloc(LPVOID pmem, ULONG ulSize);
  714. STDAPI_(void) OleStdFree(LPVOID pmem);
  715. STDAPI_(ULONG) OleStdGetSize(LPVOID pmem);
  716. STDAPI_(void) OleStdFreeString(LPSTR lpsz, LPMALLOC lpMalloc);
  717. STDAPI_(LPSTR) OleStdCopyString(LPSTR lpszSrc, LPMALLOC lpMalloc);
  718. STDAPI_(ULONG) OleStdGetItemToken(LPSTR lpszSrc, LPSTR lpszDst,int nMaxChars);
  719.  
  720. STDAPI_(UINT)     OleStdIconLabelTextOut(HDC        hDC,
  721.                                          HFONT      hFont,
  722.                                          int        nXStart,
  723.                                          int        nYStart,
  724.                                          UINT       fuOptions,
  725.                                          RECT FAR * lpRect,
  726.                                          LPSTR      lpszString,
  727.                                          UINT       cchString,
  728.                                          int FAR *  lpDX);
  729.  
  730. // registration database query functions
  731. STDAPI_(UINT)     OleStdGetAuxUserType(REFCLSID rclsid,
  732.                                       WORD   wAuxUserType,
  733.                                       LPSTR  lpszAuxUserType,
  734.                                       int    cch,
  735.                                       HKEY   hKey);
  736.  
  737. STDAPI_(UINT)     OleStdGetUserTypeOfClass(REFCLSID rclsid,
  738.                                            LPSTR lpszUserType,
  739.                                            UINT cch,
  740.                                            HKEY hKey);
  741.  
  742. STDAPI_(BOOL) OleStdGetMiscStatusOfClass(REFCLSID, HKEY, DWORD FAR *);
  743. STDAPI_(CLIPFORMAT) OleStdGetDefaultFileFormatOfClass(
  744.         REFCLSID        rclsid,
  745.         HKEY            hKey
  746. );
  747.  
  748. STDAPI_(void) OleStdInitVtbl(LPVOID lpVtbl, UINT nSizeOfVtbl);
  749. STDMETHODIMP OleStdNullMethod(LPUNKNOWN lpThis);
  750. STDAPI_(BOOL) OleStdCheckVtbl(LPVOID lpVtbl, UINT nSizeOfVtbl, LPSTR lpszIface);
  751. STDAPI_(ULONG) OleStdVerifyRelease(LPUNKNOWN lpUnk, LPSTR lpszMsg);
  752. STDAPI_(ULONG) OleStdRelease(LPUNKNOWN lpUnk);
  753.  
  754. STDAPI_(HDC) OleStdCreateDC(DVTARGETDEVICE FAR* ptd);
  755. STDAPI_(HDC) OleStdCreateIC(DVTARGETDEVICE FAR* ptd);
  756. STDAPI_(DVTARGETDEVICE FAR*) OleStdCreateTargetDevice(LPPRINTDLG lpPrintDlg);
  757. STDAPI_(BOOL) OleStdDeleteTargetDevice(DVTARGETDEVICE FAR* ptd);
  758. STDAPI_(DVTARGETDEVICE FAR*) OleStdCopyTargetDevice(DVTARGETDEVICE FAR* ptdSrc);
  759. STDAPI_(BOOL) OleStdCopyFormatEtc(LPFORMATETC petcDest, LPFORMATETC petcSrc);
  760. STDAPI_(int) OleStdCompareFormatEtc(FORMATETC FAR* pFetcLeft, FORMATETC FAR* pFetcRight);
  761. STDAPI_(BOOL) OleStdCompareTargetDevice
  762.     (DVTARGETDEVICE FAR* ptdLeft, DVTARGETDEVICE FAR* ptdRight);
  763.  
  764.  
  765. STDAPI_(void) OleDbgPrint(
  766.         int     nDbgLvl,
  767.         LPSTR   lpszPrefix,
  768.         LPSTR   lpszMsg,
  769.         int     nIndent
  770. );
  771. STDAPI_(void) OleDbgPrintAlways(LPSTR lpszPrefix, LPSTR lpszMsg, int nIndent);
  772. STDAPI_(void) OleDbgSetDbgLevel(int nDbgLvl);
  773. STDAPI_(int) OleDbgGetDbgLevel( void );
  774. STDAPI_(void) OleDbgIndent(int n);
  775. STDAPI_(void) OleDbgPrintRefCnt(
  776.         int         nDbgLvl,
  777.         LPSTR       lpszPrefix,
  778.         LPSTR       lpszMsg,
  779.         LPVOID      lpObj,
  780.         ULONG       refcnt
  781. );
  782. STDAPI_(void) OleDbgPrintRefCntAlways(
  783.         LPSTR       lpszPrefix,
  784.         LPSTR       lpszMsg,
  785.         LPVOID      lpObj,
  786.         ULONG       refcnt
  787. );
  788. STDAPI_(void) OleDbgPrintRect(
  789.         int         nDbgLvl,
  790.         LPSTR       lpszPrefix,
  791.         LPSTR       lpszMsg,
  792.         LPRECT      lpRect
  793. );
  794. STDAPI_(void) OleDbgPrintRectAlways(
  795.         LPSTR       lpszPrefix,
  796.         LPSTR       lpszMsg,
  797.         LPRECT      lpRect
  798. );
  799. STDAPI_(void) OleDbgPrintScodeAlways(LPSTR lpszPrefix, LPSTR lpszMsg, SCODE sc);
  800.  
  801. // debug implementation of the IMalloc interface.
  802. STDAPI OleStdCreateDbAlloc(ULONG reserved, IMalloc FAR* FAR* ppmalloc);
  803.  
  804.  
  805. STDAPI_(LPENUMFORMATETC)
  806.   OleStdEnumFmtEtc_Create(ULONG nCount, LPFORMATETC lpEtc);
  807.  
  808. STDAPI_(LPENUMSTATDATA)
  809.   OleStdEnumStatData_Create(ULONG nCount, LPSTATDATA lpStat);
  810.  
  811. STDAPI_(BOOL)
  812.   OleStdCopyStatData(LPSTATDATA pDest, LPSTATDATA pSrc);
  813.  
  814. STDAPI_(HPALETTE)
  815.   OleStdCreateStandardPalette(void);
  816.  
  817. #if defined( OBSOLETE )
  818.  
  819. /*************************************************************************
  820. ** The following API's have been converted into macros:
  821. **          OleStdQueryOleObjectData
  822. **          OleStdQueryLinkSourceData
  823. **          OleStdQueryObjectDescriptorData
  824. **          OleStdQueryFormatMedium
  825. **          OleStdCopyMetafilePict
  826. **          AreRectsEqual
  827. **          OleStdGetDropEffect
  828. **
  829. **    These macros are defined above
  830. *************************************************************************/
  831. STDAPI_(BOOL) AreRectsEqual(LPRECT lprc1, LPRECT lprc2);
  832. STDAPI_(BOOL) OleStdCopyMetafilePict(HANDLE hpictin, HANDLE FAR* phpictout);
  833. STDAPI OleStdQueryOleObjectData(LPFORMATETC lpformatetc);
  834. STDAPI OleStdQueryLinkSourceData(LPFORMATETC lpformatetc);
  835. STDAPI OleStdQueryObjectDescriptorData(LPFORMATETC lpformatetc);
  836. STDAPI OleStdQueryFormatMedium(LPFORMATETC lpformatetc, TYMED tymed);
  837. STDAPI_(DWORD) OleStdGetDropEffect ( DWORD grfKeyState );
  838. #endif  // OBSOLETE
  839.  
  840.  
  841. #endif // _OLESTD_H_
  842.